/*
 *  Poly.h
 *  SDL_OpenGL_Test
 *
 *  Created by Michael McArthur on 9/26/09.
 *  Copyright 2009 __MyCompanyName__. All rights reserved.
 *
 */

#ifndef GUARD_Poly_h
#define GUARD_Poly_h

#include <vector>
#include "Vector2.h"
#include "SDL.h"

enum PolygonType
{
	SQUARE,
	TRIANGLE
};

struct CollisionAxis
{
	Vector2 axis;
	float overlap;
	std::vector< Vector2* > contactPoints;
	
	CollisionAxis(Vector2 a, float over): axis(a), overlap(over){}
};

class Poly
	{
	private:
		Vector2 centroid;
		std::vector< Vector2 > vertices;
		float xVel, yVel, speed;
		
		void calculateCentroid();
	public:
		Poly( std::vector<Vector2> verts );
		Poly( PolygonType type );
		
		void translate(Vector2 tv);
		Vector2 getCentroid();
		
		void addVertex( Vector2 vert );
		void draw();
		CollisionAxis findSeparatingAxis ( Poly& p );
		std::vector<Vector2>* getVertices();
		
		void handleEvent(SDL_Event* event);
		void update(Poly& p);
	};

CollisionAxis testCollision( Poly& p1, Poly& p2);


#endif